#include <iostream>
#include <string>
using namespace std;
class SalesItem {
public:
    SalesItem() = default;
    SalesItem(const string &isbn, int unitsSold, double sellingPrice, double salePrice)
        : _bookNo(isbn), _unitsSold(unitsSold), _sellingPrice(sellingPrice), _salePrice(salePrice) {
            updateTotalRevenue();
        }
    string isbn() const {
        return _bookNo;
    }
    friend istream& operator>>(istream &in, SalesItem &item) {
        cin >> item._bookNo >> item._unitsSold >> item._sellingPrice >> item._salePrice;
        item.updateTotalRevenue();
        return cin;
    }
    friend ostream& operator<<(ostream &out, const SalesItem &item) {
        cout << "ISBN: " << item._bookNo << "\n"
            << "Units sold: " << item._unitsSold << "\n"
            << "Selling price: " << item._sellingPrice << "\n"
            << "Sale price: " << item._salePrice << "\n";
        return cout;
    }
    SalesItem& operator=(const SalesItem &other) {
        if (this != &other) {
            _bookNo = other._bookNo;
            _unitsSold = other._unitsSold;
            _sellingPrice = other._sellingPrice;
            _salePrice = other._salePrice;
            _totalRevenue = other._totalRevenue;
        }
        return *this;
    }
    void combine(const SalesItem &other) {
        if (_bookNo == other._bookNo) {
            _unitsSold += other._unitsSold;
            updateTotalRevenue();
        }
    }
private:
    string _bookNo;
    int _unitsSold = 0;
    double _sellingPrice = 0.0;
    double _salePrice = 0.0;
    double _totalRevenue = 0.0;
    void updateTotalRevenue() {
        _totalRevenue = _unitsSold * _salePrice;
    }
};
int main() {
    SalesItem item1, item2;
    cout << "Enter details for item1 (ISBN, units sold, selling price, sale price): ";
    cin >> item1;
    cout << "Enter details for item2 (ISBN, units sold, selling price, sale price): ";
    cin >> item2;
    cout << "\nItem1 details:\n" << item1 << "\n";
    cout << "Item2 details:\n" << item2 << "\n";
    item1.combine(item2);
    cout << "Combined item1 with item2:\n" << item1 << "\n";
    return 0;
}